home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / mac / DOS / TELECOMM / PCCP047 / FAXMANIP.C < prev    next >
C/C++ Source or Header  |  1992-08-22  |  3KB  |  162 lines

  1. /* Copyright (C) 1992 Peter Edward Cann */
  2.  
  3. #include<stdio.h>
  4. #include<dos.h>
  5. #include<process.h>
  6. #include<graph.h>
  7. #include<time.h>
  8.  
  9. #define MAXTIMES 1024
  10.  
  11. long times[MAXTIMES];
  12.  
  13. int ntimes;
  14.  
  15. main(argc, argv)
  16.     int argc;
  17.     char **argv;
  18.     {
  19.     int i, j, topind, curind, flag;
  20.     char str[16], c;
  21.     long tmptime;
  22.     struct tm *tptr;
  23.     struct find_t buf;
  24.     printf("FAXMANIP Copyright (C) 1992 Peter Edward Cann\n");
  25.     if(_dos_findfirst("*.rfx", _A_NORMAL, &buf))
  26.         {
  27.         printf("No .rfx files found in current directory.\n");
  28.         exit(1);
  29.         }
  30.     ntimes=0;
  31.     if(sscanf(buf.name, "%lx", ×[ntimes++])!=1)
  32.         ntimes--;
  33.     while(!_dos_findnext(&buf))
  34.         {
  35.         if(sscanf(buf.name, "%lx", ×[ntimes++])!=1)
  36.             ntimes--;
  37.         if(ntimes>=MAXTIMES)
  38.             break;
  39.         }
  40.     for(i=0;i<ntimes;++i)
  41.         for(j=i+1;j<ntimes;++j)
  42.             if(times[i]<times[j])
  43.                 {
  44.                 tmptime=times[i];
  45.                 times[i]=times[j];
  46.                 times[j]=tmptime;
  47.                 }
  48.     topind=curind=0;
  49.     while(1)
  50.         {
  51.         _settextwindow(1,1,1,80);
  52.         _settextcolor(0);
  53.         _setbkcolor((long)7);
  54.         _clearscreen(_GWINDOW);
  55.         printf("              n=next   p=previous   c=convert   d=delete   q=quit");
  56.         _settextwindow(2,1,25,80);
  57.         _settextcolor(7);
  58.         _setbkcolor((long)0);
  59.         _clearscreen(_GWINDOW);
  60.         for(i=0;(i<24)&&(i<(ntimes-topind));++i)
  61.             {
  62.             tptr=localtime(×[topind+i]);
  63.             _settextposition(i+1, 1);
  64.             printf("%02d.%02d.%02d @ %02d:%02d:%02d",
  65.                 tptr->tm_year,
  66.                 (tptr->tm_mon)+1,
  67.                 tptr->tm_mday,
  68.                 tptr->tm_hour,
  69.                 tptr->tm_min,
  70.                 tptr->tm_sec
  71.                 );
  72.             }
  73.         flag=1;
  74.         while((curind-topind<24)&&(curind>=topind)&&flag)
  75.             {
  76.             _settextposition(curind-topind+1, 21);
  77.             switch(getch())
  78.                 {
  79.                 case 'n':
  80.                 case 'N':
  81.                     if(curind>=(ntimes-1))
  82.                         putch(0x07);
  83.                     else
  84.                         curind++;
  85.                     break;
  86.                 case 'p':
  87.                 case 'P':
  88.                     if(curind==0)
  89.                         putch(0x07);
  90.                     else
  91.                         curind--;
  92.                     break;
  93.                 case 'q':
  94.                 case 'Q':
  95.                     _settextposition(24, 1);
  96.                     exit(0);
  97.                     break;
  98.                 case 'd':
  99.                 case 'D':
  100.                     printf("Really delete? (Y/N) --> ");
  101.                     c=getch();
  102.                     if((c!='Y')&&(c!='y'))
  103.                         {
  104.                         _settextposition(curind-topind+1, 21);
  105.                         printf("\t\t\t\t");
  106.                         break;
  107.                         }
  108.                     sprintf(str, "%08lx.rfx", times[curind]);
  109.                     unlink(str);
  110.                     --ntimes;
  111.                     if(!ntimes)
  112.                         {
  113.                         _settextposition(24,1);
  114.                         printf("\nNo more faxes.\n");
  115.                         exit(0);
  116.                         }
  117.                     for(i=curind;i<ntimes;++i)
  118.                         times[i]=times[i+1];
  119.                     if(curind==ntimes)
  120.                         curind--;
  121.                     flag=0;
  122.                     break;
  123.                 case 'c':
  124.                 case 'C':
  125.                     _settextposition(24,1);
  126.                     printf("\nSpawning RFXTOPCX...\n");
  127.                     sprintf(str, "%08lx.rfx", times[curind]);
  128.                     if(argc==2)
  129.                         spawnlp(P_WAIT, "rfxtopcx", "rfxtopcx", str, "/debug", NULL);
  130.                     else
  131.                         spawnlp(P_WAIT, "rfxtopcx", "rfxtopcx", str, NULL);
  132.                     printf("\nPress any key to resume faxmanip: --> ");
  133.                     getch();
  134.                     flag=0;
  135.                     break;
  136.                 case 'e':
  137.                 case 'E':
  138.                     if(argc!=2)
  139.                         {
  140.                         putch(0x07);
  141.                         break;
  142.                         }
  143.                     _settextposition(24,1);
  144.                     printf("\nCalling editor...\n");
  145.                     sprintf(str, "%s %08lx.rfx", argv[1], times[curind]);
  146.                     system(str);
  147.                     printf("\nPress any key to resume faxmanip: --> ");
  148.                     getch();
  149.                     flag=0;
  150.                     break;
  151.                 default:
  152.                     putch(0x07);
  153.                     break;
  154.                 }
  155.             }
  156.         if(curind>12)
  157.             topind=curind-12;
  158.         else
  159.             topind=0;
  160.         }
  161.     }
  162.